package jsyf.oa.web.report.intentCustomer;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import jsyf.com.util.BaseUtils;
import jsyf.com.util.FastJsonConvert;
import jsyf.com.util.ResponseUtils;
import jsyf.oa.facade.report.intentCustomer.ReportCustomerFacade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by Administrator on 2018/4/5.
 */
@Api(value = "意向客户", description = "意向客户")
@Controller
@RequestMapping("/intentCustomer")
public class ReportCustomerController {

    @Resource
    private ReportCustomerFacade reportCustomerFacade;

    @ResponseBody
    @RequestMapping(value = "/getForPersonalIntentCustomerList.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取个人意向客户",
            notes = "获取个人意向客户",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{'userId':'',key:''}", dataType = "String", paramType = "body")
    public void getForPersonalIntentCustomerList(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject jsonObjectList = reportCustomerFacade.getForPersonalIntentCustomerList(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjHourRespond(jsonObjectList));
    }
    @ResponseBody
    @RequestMapping(value = "/getForDepartIntentCustomerList.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取部门意向客户",
            notes = "获取部门意向客户",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{'userId':''}", dataType = "String", paramType = "body")
    public void getForDepartIntentCustomerList(HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> jsonObjectList = reportCustomerFacade.getForDepartIntentCustomerList(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(jsonObjectList));
    }

    @ResponseBody
    @RequestMapping(value = "/getForCompanyIntentCustomerList.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取公司意向客户",
            notes = "获取公司意向客户",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{'userId':''}", dataType = "String", paramType = "body")
    public void getForCompanyIntentCustomerList(HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> jsonObjectList = reportCustomerFacade.getForCompanyIntentCustomerList(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(jsonObjectList));
    }

    @ResponseBody
    @RequestMapping(value = "/getForGroupIntentCustomerList.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取集团意向客户",
            notes = "获取集团意向客户",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{'userId':''}", dataType = "String", paramType = "body")
    public void getForGroupIntentCustomerList(HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> jsonObjectList = reportCustomerFacade.getForGroupIntentCustomerList(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(jsonObjectList));
    }

    @ResponseBody
    @RequestMapping(value = "/getAllReportCustomer.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取全部意向客户",
            notes = "获取全部意向客户",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{userId:'',key:''}", dataType = "String", paramType = "body")
    public void getAllReportCustomer(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject jsonObjectList = reportCustomerFacade.getAllReportCustomer(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(jsonObjectList));
    }

    @ResponseBody
    @RequestMapping(value = "/getForDepartByCompanyId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取集团下的部门",
            notes = "获取集团下的部门",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{companyId:''}", dataType = "String", paramType = "body")
    public void getForDepartByCompanyId(HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> jsonObjectList = reportCustomerFacade.getForDepartByCompanyId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrRespond(jsonObjectList));
    }

    /*获取APP大区经理*/
    @ResponseBody
    @RequestMapping(value = "/getForAppBigRegionIntentCustomerList.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取APP大区意向客户",
            notes = "获取APP大区意向客户",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{'userId':''}", dataType = "String", paramType = "body")
    public void getForAppBigRegionIntentCustomerList(HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> jsonObjectList = reportCustomerFacade.getForAppBigRegionIntentCustomerList(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrYearTimeRespond(jsonObjectList));
    }
    /*获取APP意向客户列表*/
    @ResponseBody
    @RequestMapping(value = "/getForAppIntentCustomerListsByUserId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取APP意向客户列表",
            notes = "获取APP意向客户列表",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{'userId':''}", dataType = "String", paramType = "body")
    public void getForAppIntentCustomerListsByUserId(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject jsonObjectList = reportCustomerFacade.getForAppIntentCustomerListsByUserId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrHourTimeRespond(jsonObjectList));
    }
    /*修改意向客户信息*/
    @ResponseBody
    @RequestMapping(value = "/saveIntentCustomerInfo.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "保存修改修改意向客户信息",
            notes = "保存修改意向客户信息",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{'customer':''}", dataType = "String", paramType = "body")
    public void saveIntentCustomerInfo(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject records = reportCustomerFacade.saveIntentCustomerInfo(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjHourRespond(records));
    }
    /*获取大区及其手下*/
    @ResponseBody
    @RequestMapping(value = "/getForUserInfo.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取大区经理下属信息",
            notes = "获取大区经理下属信息",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{'userId':''}", dataType = "String", paramType = "body")
    public void getForUserInfo(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject records = reportCustomerFacade.getForUserInfo(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjHourRespond(records));
    }
    /*查询所在地*/
    @ResponseBody
    @RequestMapping(value = "/getForProvinceById.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "查询所在地",
            notes = "查询所在地",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{'id':''}", dataType = "String", paramType = "body")
    public void getForProvinceById(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject jsonObjectList = reportCustomerFacade.getForProvinceById(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrHourTimeRespond(jsonObjectList));
    }
}